package com.wuhao.shootclient.adapter;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wuhao.shootclient.R;
import com.wuhao.shootclient.bean.ShootDataVo;
import com.wuhao.shootclient.bean.ShootFireVo;
import com.wuhao.shootclient.util.StrUtil;

import java.math.BigDecimal;
import java.util.List;

/**
 * Create by hao on 2019-10-29
 */
public class ItemAdapter extends BaseQuickAdapter<ShootFireVo, BaseViewHolder> {

    public ItemAdapter(@Nullable List<ShootFireVo> data) {
        super(R.layout.item_list, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ShootFireVo item) {
        int posit = helper.getAdapterPosition();
        BigDecimal bigDecimalScore = new BigDecimal(item.getScore());
        if (item.isEnable_circle_float()){
            helper.setText(R.id.tv_index, "第" + posit + "发")
                    .setText(R.id.tv_total_ring, item.getAllScore()+"环")
                    .setText(R.id.tv_angle, item.getOrientation());
        }
        else {
            helper.setText(R.id.tv_index, "第" + posit + "发")
                    .setText(R.id.tv_total_ring, StrUtil.Format(item.getAllScore())+"环")
                    .setText(R.id.tv_angle, item.getOrientation());
        }
      //  String mStrScore = String.valueOf(item.getScore()).replace(".0", "");
        if (0.0 == bigDecimalScore.doubleValue()) {
            helper.setText(R.id.tv_ring, "脱靶");

        } else {
            if (item.isEnable_circle_float()){
                helper.setText(R.id.tv_ring,item.getScore()  + "环");
            }
            else {
                helper.setText(R.id.tv_ring, StrUtil.Format(item.getScore()) + "环");
            }

        }
    }
}
